<?php
use_helper('I18N');
?>

<style>
    .column {
        width: 50%;
        float: left;
        padding-bottom: 100px;
    }

    .portlet {
        margin: 0 1em 1em 0;
    }

    .portlet-header {
        margin: 0.3em;
        padding-top: 5px;
        padding-bottom: 5px;
        padding-left: 0.5em;
    }

    .portlet-header .ui-icon {
        float: right;
    }

    .portlet-content {
        padding: 1em;
    }

    .ui-sortable-placeholder {
        border: 1px dotted black;
        visibility: visible !important;
        height: 50px !important;
    }

    .ui-sortable-placeholder * {
        visibility: hidden;
    }
</style>
<script type="text/javascript">
var datagrid = null;
var datagridEPointPurchase = null;
var datagridPackageUpgradeHistory = null;
var datagridPackagePurchase = null;
$(function() {
    $(".column").sortable({
        connectWith: ".column"
    });
    datagridEPointPurchase = $("#datagridEPointPurchase").r9jasonDataTable({
        // online1DataTable extra params
        "idTr" : true, // assign <tr id='xxx'> from 1st columns array(aoColumns);
        "extraParam" : function(aoData) { // pass extra params to server
            aoData.push({ "name": "filterUsername", "value": $("#search_username").val()  });
            aoData.push({ "name": "filterStatusCode", "value": '<?php echo Globals::STATUS_PENDING;?>'  });
        },
        "reassignEvent" : function() { // extra function for reassignEvent when JSON is back from server
        },

        // datatables params
        "bLengthChange": true,
        "bFilter": false,
        "bProcessing": true,
        "bServerSide": true,
        "bAutoWidth": false,
        "sAjaxSource": "<?php echo url_for('financeList/epointPurchaseList') ?>",
        "sPaginationType": "full_numbers",
        "aoColumns": [
            { "sName" : "purchase.purchase_id", "bVisible" : false},
            { "sName" : "purchase.purchase_id", "bVisible" : false},
            { "sName" : "dist.distributor_code",  "bSortable": true, "fnRender": function ( oObj ) {
                return "<a id='editLink' href='<?php echo url_for('finance/epointPurchaseEdit?q=dsf453fsdfasf1sxfsdfs&purchaseId=') ?>/" + oObj.aData[0] + "'>" + oObj.aData[2] + "</a>";
            }},
            { "sName" : "dist.full_name",  "bVisible": false},
            { "sName" : "purchase.amount",  "bSortable": true},
            { "sName" : "purchase.transaction_type",  "bSortable": true},
            { "sName" : "purchase.status_code",  "bVisible": false},
            { "sName" : "purchase.image_src",  "bVisible": false},
            { "sName" : "purchase.payment_reference",  "bVisible": false},
            { "sName" : "purchase.approve_reject_datetime",  "bVisible": false},
            { "sName" : "purchase.created_on",  "bSortable": true},
            { "sName" : "purchase.created_on",  "bVisible": false}
        ]
    });
});

function reassignDatagridEventAttr(){
    $("a[id=updateMT4Link]").click(function(event){
		// stop event
		event.preventDefault();

		// event.target is <a> itself, parent() is <td>, while parent().parent() get <tr>
		//var id = alert("id = " +$(event.target).parent().parent().attr("id"));
		var id = $(event.target).parent().parent().attr("id");
        $("#dgAddPanelId").val(id);
        $("#dgAddPanel").dialog("open");
	});
}
</script>

<div class="demo" style="padding:6px">
    <div class="column">
        <div class="portlet">
            <div class="portlet-header">Company Information</div>
            <div class="portlet-content">
                <table cellpadding="3" cellspacing="3" width="100%">
                    <tr>
                        <td><strong>Withdrawal</strong></td>
                        <td align="right"><?php
                            if ($ecashWithdrawal > 0)
                                echo "<a id='editLink' href='".url_for('finance/ecashWithdrawal')."'>".$ecashWithdrawal."</a>";
                            else
                                echo $ecashWithdrawal;
                            ?>
                        </td>
                    </tr>
                    <tr>
                        <td><strong>Fund Deposit</strong></td>
                        <td align="right"><?php
                            if ($ecashWithdrawal > 0)
                                echo "<a id='editLink' href='".url_for('finance/epointPurchase')."'>".$epointPurchase."</a>";
                            else
                                echo $epointPurchase;
                            ?>
                        </td>
                    </tr>
                </table>
            </div>
        </div>

    </div>

    <div class="column">
        <!--<div class="portlet">
            <div class="portlet-header">e-Point Purchase</div>
            <div class="portlet-content">
                <table class="display" id="datagridEPointPurchase" border="0" width="100%" cellpadding="0" cellspacing="0">
                    <thead>
                    <tr>
                        <th>purchase id [hidden]</th>
                        <th></th>
                        <th>e-Trader</th>
                        <th>Full Name</th>
                        <th>Amount</th>
                        <th>Transaction Type</th>
                        <th>Status</th>
                        <th>Image</th>
                        <th>Payment Reference</th>
                        <th>Approved/Reject Date</th>
                        <th>Purchased Date</th>
                        <th>Leader</th>
                    </tr>
                    <tr>
                        <td></td>
                        <td></td>
                        <td><input title="" size="10" type="text" id="search_username" value="" class="search_init"/></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>-->
    </div>
</div>

<!--######################################################################################-->
<!--######################################################################################-->
<!--######################################################################################-->